using System;
using System.Collections;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using Common;
using Common.Enum;

namespace Converters
{
	public class ColorMultiConverter : IMultiValueConverter
	{
		public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
		{
			if (parameter.ToString().Equals("Target"))
			{
				if (value.Length == 4 && value[0] != null && value[0] != DependencyProperty.UnsetValue && value[0] is bool && value[1] != null && value[1] != DependencyProperty.UnsetValue && value[1] is bool && value[2] != null && value[2] != DependencyProperty.UnsetValue && value[3] != null && value[3] != DependencyProperty.UnsetValue && value[3] is IList)
				{
					bool flag = (bool)value[0];
					bool flag2 = (bool)value[1];
					int num = ((IList)value[3]).IndexOf(value[2]);
					if (!flag)
					{
						return SLANDefine.Color_Gray;
					}
					if (!flag2 && num >= 3)
					{
						return SLANDefine.Color_Gray;
					}
				}
			}
			else if (parameter.ToString().Equals("IsEnabled"))
			{
				if (value.Length == 1 && value[0] != null && value[0] != DependencyProperty.UnsetValue && value[0] is bool && !(bool)value[0])
				{
					return SLANDefine.Color_Gray;
				}
			}
			else if (parameter.ToString().Equals("Threshold"))
			{
				if (value.Length == 2 && value[0] != null && value[1] != null && value[0] != DependencyProperty.UnsetValue && value[1] != DependencyProperty.UnsetValue)
				{
					EAnalysisType eAnalysisType = (EAnalysisType)value[0];
					if (eAnalysisType == EAnalysisType.ANALYSIS_QUANTITATIVE && (bool)value[1])
					{
						return SLANDefine.Color_Gray;
					}
				}
			}
			else if (parameter.ToString().Equals("CrossTalkChannel") && value.Length == 2 && value[0] != null && value[1] != null && value[0] != DependencyProperty.UnsetValue && value[1] != DependencyProperty.UnsetValue)
			{
				int num2 = int.Parse(value[0].ToString());
				int num3 = (int)value[1];
				if (num2 == num3)
				{
					return SLANDefine.Color_Gray;
				}
			}
			return Colors.Transparent;
		}

		public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
		{
			return null;
		}
	}
}
